# -*- coding: utf-8 -*- 
# @project : 《Atcoder》
# @Author : created by bensonrachel on 2021/9/26
# @File : 14.Removing Digits.py
# https://cses.fi/problemset/task/1637/
import sys
MaxInt = sys.maxsize

def dp_solve():
    dp = [MaxInt]*(1000001)
    dp[0] = 0
    for i in range(1,10):
        dp[i] = 1
    for i in range(10,n+1):
        tmp = MaxInt
        for item in str(i):#有从整数转字符串，再转回来。
            tmp = min(tmp,dp[i-int(item)]+1)
        dp[i] = tmp
    return dp[n]
"""
每次从此整数的每一位数字中挑一个步数最少的转移到此整数作为dp值：即tmp = min(tmp,dp[i-int(item)]+1)，就能找到每一个数跳到0的最少步数。
"""
if __name__ == '__main__':
    n = int(input())
    ans = dp_solve()
    print(ans)
